package com.mtoolkit.jdbc.handler;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Long number result set call back handler.
 * 
 * @author 	<a href="mailto:xishizhang@gmail.com">ZhangShixi</a>
 * @version 1.0, 12/7/2011
 * @since 	JDK1.5
 */
public class LongResultSetHandler implements ResultSetHandler<Long> {

	/**
     * Handles the result set and return long result.
     * 
     * @param  rs result set.
     * 
     * @return long result.
     * 
     * @throws SQLException if a sql error occurs whiling handle result set.
     */ 
    @Override
    public Long handle(ResultSet rs) throws SQLException {
        if (rs.next()) {
            return Long.valueOf(rs.getLong(1));
        } else {
            return null;
        }
    }
    
}
